/** * footer-loader.js * Fetches /footer.html and injects it into every page * that has a placeholder. */ (function () { function loadFooter() { var placeholder = document.getElementById('site-footer'); if (!placeholder) return; fetch('/footer.html') .then(function (response) { if (!response.ok) { throw new Error('Failed to load footer: ' + response.status); } return response.text(); }) .then(function (html) { placeholder.innerHTML = html; }) .catch(function (err) { console.error(err); }); } // Run after DOM is ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', loadFooter); } else { loadFooter(); } })();